﻿using System;
using System.Collections.Generic;

using System.Text;

namespace DTO
{
    public class Device : BaseDTO
    {
        #region Fields
        #endregion

        #region Properties
        public string Code { get; set; }
        public string Name { get; set; }
        public string IP { get; set; }
        public double Fee 
        { 
            get 
            { 
                double amount = 0;

                if ( Plan != null )
                    amount += Plan.MonthlyFee;

                if ( OS != null )
                    amount += OS.Fee;

                return amount;
            } 
        }
        public PlanType Plan { get; set; }
        public OperatingSystem OS { get; set; }
        #endregion

        #region Constructors
        public Device () : this(0) { }
        public Device (int id) : base(id)
        {
        }        
        #endregion

        #region Private Methods
        #endregion

        #region Public Methods
        public static Device Sample (string code, string name, string ip, int plan, int os)
        {
            return new Device()
            {
                Code = code,
                Name = name,
                IP = ip,
                Plan = PlanType.Sample(plan),
                OS = OperatingSystem.Sample(os)
            };
        }
        #endregion

        public class PlanType : BaseDTO
        {
            #region Fields
            #endregion

            #region Properties
            public string Name { get; set; }
            public int CPUs { get; set; }
            public int RAM { get; set; }
            public int DiskQuota { get; set; }
            public int Bandwidth { get; set; }
            public double MonthlyFee { get; set; }
            public double ProratedFee { get; set; }
            #endregion

            #region Constructors
            public PlanType () : this(0) { }
            public PlanType ( int id )
                : base(id)
            {
            }        
            #endregion

            #region Private Methods
            #endregion

            #region Public Methods
            public static PlanType Sample ( int index )
            {
                PlanType plan = null;

                switch ( index )
                {
                    case 1:
                        plan = new PlanType()
                        {
                            Name = "Plan A",
                            CPUs = 1,
                            RAM = 1,
                            DiskQuota = 30,
                            Bandwidth = 200,
                            MonthlyFee = 99
                        };
                        break;
                    case 2:
                        plan = new PlanType()
                        {
                            Name = "Plan B",
                            CPUs = 2,
                            RAM = 2,
                            DiskQuota = 40,
                            Bandwidth = 200,
                            MonthlyFee = 178
                        };
                        break;
                    case 3:
                        plan = new PlanType()
                        {
                            Name = "Plan C",
                            CPUs = 4,
                            RAM = 4,
                            DiskQuota = 60,
                            Bandwidth = 200,
                            MonthlyFee = 336
                        };
                        break;
                }

                return plan;
            }
            #endregion
        }

        public class OperatingSystem : BaseDTO
        {
            #region Fields
            #endregion

            #region Properties
            public string Name { get; set; }
            public double Fee { get; set; }
            #endregion

            #region Constructors
            public OperatingSystem () : this(0) { }
            public OperatingSystem ( int id ) : base(id) { }        
            #endregion

            #region Private Methods
            #endregion

            #region Public Methods
            public static OperatingSystem Sample (int index)
            {
                OperatingSystem os = null;

                switch (index)
                {
                    case 1:
                        os = new OperatingSystem(1){ Name = "Windows 2003 R2 - Standard - 32 Bit" };
                        break;
                    case 2:
                        os = new OperatingSystem(1) { Name = "Windows 2003 R2 - Standard - 64 Bit" };
                        break;
                    case 3:
                        os = new OperatingSystem(1) { Name = "Windows 2008 R2 - Standard - 32 Bit" };
                        break;
                    case 4:
                        os = new OperatingSystem(1) { Name = "Windows 2008 R2 - Standard - 64 Bit" };
                        break;
                    case 5:
                        os = new OperatingSystem(1) { Name = "Windows 2008 R2 - Standard - 64 Bit - IIS 7.5" };
                        break;
                }

                return os;
            }
            #endregion
       }
    }
}
